
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.annotation.AliasFor;

/**
 * When used as a type-level annotation in conjunction with
 * {@link org.springframework.stereotype.Component @Component},
 * {@code @Scope} indicates the name of a scope to use for instances of
 * the annotated type.
 *
 * <p>When used as a method-level annotation in conjunction with
 * {@link Bean @Bean}, {@code @Scope} indicates the name of a scope to use
 * for the instance returned from the method.
 *
 * <p><b>NOTE:</b> {@code @Scope} annotations are only introspected on the
 * concrete bean class (for annotated components) or the factory method
 * (for {@code @Bean} methods). In contrast to XML bean definitions,
 * there is no notion of bean definition inheritance, and inheritance
 * hierarchies at the class level are irrelevant for metadata purposes.
 *
 * <p>In this context, <em>scope</em> means the lifecycle of an instance,
 * such as {@code singleton}, {@code prototype}, and so forth. Scopes
 * provided out of the box in Spring may be referred to using the
 * {@code SCOPE_*} constants available in the {@link ConfigurableBeanFactory}
 * and {@code WebApplicationContext} interfaces.
 *
 * <p>To register additional custom scopes, see
 * {@link org.springframework.beans.factory.config.CustomScopeConfigurer
 * CustomScopeConfigurer}.
 *
 * @author Mark Fisher
 * @author Chris Beams
 * @author Sam Brannen
 * @since 2.5
 * @see org.springframework.stereotype.Component
 * @see org.springframework.context.annotation.Bean
 */
/**
 *与一起用作类型级注释时
 *｛@link org.springframework.stereotype.Component@Component｝，
 *｛@code@Scope｝表示要用于的实例的作用域的名称
 *注释类型。
 *
 *<p>当与一起用作方法级注释时
 *｛@link-Bean@Bean｝，｛@code@Scope｝表示要使用的作用域的名称
 *用于从方法返回的实例。
 *
 *<p><b>注意：</b>｛@code@Scope｝注释仅在
 *具体bean类（用于带注释的组件）或工厂方法
 *（对于{@code@Bean}方法）。与XML bean定义相反，
 *没有bean定义继承和继承的概念
 *类级别的层次结构与元数据目的无关。
 *
 *<p>在此上下文中，<em>scope</em>表示实例的生命周期，
 *例如{@code singleton}、{@code prototype}等等。范围
 *在Spring中提供的开箱即用的
 *｛@code SCOPE_*｝常量在｛@link ConfigurationBeanFactory｝中可用
 *和{@code WebApplicationContext}接口。
 *
 *<p>若要注册其他自定义作用域，请参阅
 *｛@link org.springframework.beans.factory.config.CustomScope配置程序
 *CustomScopeConfigurer｝。
 *
 *@作者Mark Fisher
 *@作者Chris Beams
 *@作者Sam Brannen
 *@自2.5起
 *@参见org.springframework.stereotype.Component
 *@参见org.springframework.context.annotation.Bean
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Scope {

	/**
	 * Alias for {@link #scopeName}.
	 * @see #scopeName
	 */
	/**
	 *｛@link#scopeName｝的别名。
	 *@参见#作用域名称
	 */
	@AliasFor("scopeName")
	String value() default "";

	/**
	 * Specifies the name of the scope to use for the annotated component/bean.
	 * <p>Defaults to an empty string ({@code ""}) which implies
	 * {@link ConfigurableBeanFactory#SCOPE_SINGLETON SCOPE_SINGLETON}.
	 * @since 4.2
	 * @see ConfigurableBeanFactory#SCOPE_PROTOTYPE
	 * @see ConfigurableBeanFactory#SCOPE_SINGLETON
	 * @see org.springframework.web.context.WebApplicationContext#SCOPE_REQUEST
	 * @see org.springframework.web.context.WebApplicationContext#SCOPE_SESSION
	 * @see #value
	 */
	/**
	 *指定要用于带注释的组件/bean的作用域的名称。
	 *<p>默认为空字符串（{@code“”}），这意味着
	 *｛@link可配置BeanFactory#SCOPE_SINGLETON SCOPE_SINGLETON｝。
	 *@自4.2起
	 *@请参阅可配置BeanFactory#SCOPE_PROTOTYPE
	 *@请参阅可配置BeanFactory#SCOPE_SINGLETON
	 *请参阅org.springframework.web.context.WebApplicationContext#SCOPE_REQUEST
	 *@请参阅org.springframework.web.context.WebApplicationContext#SCOPE_SESSION
	 *@见#值
	 */
	@AliasFor("value")
	String scopeName() default "";

	/**
	 * Specifies whether a component should be configured as a scoped proxy
	 * and if so, whether the proxy should be interface-based or subclass-based.
	 * <p>Defaults to {@link ScopedProxyMode#DEFAULT}, which typically indicates
	 * that no scoped proxy should be created unless a different default
	 * has been configured at the component-scan instruction level.
	 * <p>Analogous to {@code <aop:scoped-proxy/>} support in Spring XML.
	 * @see ScopedProxyMode
	 */
	/**
	 *指定是否应将组件配置为作用域代理
	 *如果是，那么代理应该是基于接口还是基于子类。
	 *＜p＞默认为｛@link ScopedProxyMode#DEFAULT｝，这通常表示
	 *除非有不同的默认值，否则不应创建任何作用域代理
	 *已在组件扫描指令级别进行了配置。
	 *＜p＞类似于Spring XML中的｛@code＜aop:scoped proxy/＞｝支持。
	 *@请参阅ScopedProxyMode
	 */
	ScopedProxyMode proxyMode() default ScopedProxyMode.DEFAULT;

}
